﻿<%@ Page Language="C#" AutoEventWireup="true" validateRequest="false" CodeBehind="WebForm1.aspx.cs" Inherits="MvcApplication1.ueditor.net.WebForm1" %>

<!DOCTYPE html>
<html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" charset="utf-8" src="../ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="../lang/zh-cn/zh-cn.js"></script>

    <script src="../jquery-1.8.2.js"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="hd_content" runat="server" Value="" />

       <div id="myEditor" style="height:500px;"></div>
    <asp:Button ID="BtnSave" runat="server" Text="保存"
         OnClick="BtnSave_Click" OnClientClick="return getContent();" CssClass="cssbtn" /> 


        <input id="btnPost1" type="button" value="Ajax Post" />
    </form>



<script type="text/javascript">
    var temp = document.getElementById("<%=hd_content.ClientID %>").value;
    var ue = new baidu.editor.ui.Editor();
    ue.render("myEditor");   //这里填写要改变为编辑器的控件id
    ue.ready(function () {
        ue.setContent(temp);
    })


    function getContent() {
        var temp = UE.getEditor('myEditor').getContent();
        //alert(temp);
        document.getElementById("<%=hd_content.ClientID %>").value = temp;
    }

    $("#btnPost1").click(function () {
        var temp = UE.getEditor('myEditor').getContent();
        $.ajax({
            type: "POST",
            url: "http://localhost:61548/Home/index",
            data: { str: "'" + temp + "'" },
            success: function (msg) {
                alert(msg);
            }
        });
    })
</script>   
</body>
</html>

